﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
namespace Fcom.VNInsurance.Web.Controllers
{
    public class InvestmentController : Fcom.VNInsurance.Web.CultureHelper.CultureController
    {
        //
        // GET: /House/
        VNInsurance.Web.Models.VNInsuranceDataContext db = new Models.VNInsuranceDataContext();

        public ActionResult Index()
        {
            return View();
        }
        //Plans
        public ActionResult Plans()
        {

            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 17 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 17);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult Plans(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 17 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //RetirementPlans
        public ActionResult RetirementPlans()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 18 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 18);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult RetirementPlans(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 18 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //ChildPlans
        public ActionResult ChildPlans()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 19 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 19);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult ChildPlans(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 19&& p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //TermDeposit
        public ActionResult TermDeposit()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 20 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 20);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult TermDeposit(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 20 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //CreditCard
        public ActionResult CreditCard()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 32&& p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 32);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult CreditCard(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 32 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }
        //Consumerloan
        public ActionResult Consumerloan()
        {
            if (User.Identity.IsAuthenticated)
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                ViewBag.FullUserinfo = client.getUserInfo(User.Identity.Name);
            }
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 33&& p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 33);

            return View(LangProduct);
        }
        [HttpPost]
        public ActionResult Consumerloan(FormCollection formdata)
        {
            bool isauth = bool.Parse(formdata["isAuth"]);
            var LangProduct = db.ProductLangs.Where(p => p.ProductID == 33 && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            var LangCatProduct = db.ProductCatLangs.Where(p => p.CatID == LangProduct.Product.ProductCat.ID && p.LangID == Request.Cookies["_culture"]["lang"]).FirstOrDefault();
            if (!isauth)
            {
                bool haveaccount = bool.Parse(formdata["haveAccount"]);
                if (haveaccount)
                {
                    return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                }
                else
                {
                    int accounttype = int.Parse(formdata["accountype"]);
                    if (accounttype == 1)
                    {
                        bool gender = bool.Parse(formdata["gender"]);
                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        DateTime dateofbirth;
                        try
                        {
                            dateofbirth = DateTime.Parse(formdata["dateofBirth"]);
                        }
                        catch
                        {
                            dateofbirth = DateTime.Now;
                        }

                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, gender, accounttype, dateofbirth))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();

                    }
                    else
                    {

                        string username = formdata["youremail"];
                        string phone = formdata["yourphone"];
                        string fullname = formdata["yourfullname"];
                        Fcom.IDLib.SaveMoneyID.AccountsynClient client = new IDLib.SaveMoneyID.AccountsynClient();
                        if (client.CreateAccountFl(username, phone, fullname, true, accounttype, DateTime.Now))
                        {
                            FormsAuthentication.SetAuthCookie(username, true);
                            return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
                        }
                        client.Close();
                    }
                }
            }
            else
            {
                return RedirectToAction("Compare", "CompanyProduct", new { ID = LangProduct.ProductID, CatName = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangCatProduct.DisplayName), Name = Fcom.VNInsurance.Web.Utils.Url.url_rewrite(LangProduct.DisplayName) });
            }
            ViewBag.LangCat = LangCatProduct;

            ViewBag.productFAQ = db.ProductFAQs.Where(p => p.LangID == Request.Cookies["_culture"]["lang"] && p.ProductID == 4);

            return View(LangProduct);
        }

    }
}
